#include<iostream>
#include<vector>
using namespace std;
int main()
{
	long long count = 0;
	int n = 0;
	vector<int> arr;
	cin >> n;
	arr.resize(n);
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}
	int i = 0;
	while (i < n)
	{
		if (arr[i] < arr[i + 1])
		{
			while (i < n && arr[i] <= arr[i + 1])
			{
				i++;
			}
			count++;
			i++;
		}
		else if (arr[i] > arr[i + 1])
		{
			while (i < n && arr[i] >= arr[i + 1])
			{
				i++;
			}
			count++;
			i++;
		}
		else
			i++;
	}
	cout << count << endl;
	return 0;
}